package com.smartleanx.module.hrm.controller.admin.oauth2;

import com.smartleanx.framework.common.pojo.CommonResult;
import com.smartleanx.module.hrm.controller.admin.tenant.vo.TenantSaveReqVO;
import com.smartleanx.module.hrm.intergration.TenantServiceProvider;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

import static com.smartleanx.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 劳安心租户")
@RestController
@RequestMapping("/hrm/oauth2/tenant")
public class Oauth2TenantController {

    @Resource
    private TenantServiceProvider tenantServiceProvider;

    @PostMapping("/create")
    @Operation(summary = "创建租户")
    @PreAuthorize("@ss.hasScope('tenant.create')")
    public CommonResult<Long> createTenant(@Valid @RequestBody TenantSaveReqVO createReqVO) {
        return success(tenantServiceProvider.createTenant(createReqVO));
    }
}
